package cn.stylefeng.guns.modular.job;


import cn.stylefeng.guns.modular.app.entity.MemberRechargeAddress;
import cn.stylefeng.guns.modular.app.service.MemberRechargeAddressService;
import cn.stylefeng.guns.modular.trc.service.TrcRechargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Component
@Slf4j
public class ScanBlocksJob {


    @Autowired
    private TrcRechargeService trcRechargeService;

    @Autowired
    private MemberRechargeAddressService memberRechargeAddressService;

    public static Map<String, MemberRechargeAddress> TRC_ADDRESS = new HashMap<>();

    /**
     * 定时任务,扫描区块
     */
    @Scheduled(fixedDelay = 1000 * 50)
    public void scanBlocksTask() throws Throwable {
        trcRechargeService.scanBlock();
    }


    @PostConstruct
    public void getTrcAddress(){
        //获取TRC地址
        TRC_ADDRESS = memberRechargeAddressService.getMemberRechargeAddress("USDT-TRC20");
    }


}
